<template>
<div class="container">
  <loading :show="isLoading" text="请稍候"></loading>
  <x-header title="订单支付"></x-header>
  <group>
      <cell title="订单号" value-align="right" :value="orderInfo.order_sn"></cell>
      <cell title="订单金额" value-align="right" :value="orderInfo.total_amount"></cell>
      <cell title="收货人" value-align="right" :value="orderInfo.consignee"></cell>
      <cell title="电话" value-align="right" :value="orderInfo.mobile"></cell>
      <cell title="地址" value-align="right" :value="orderInfo.address"></cell>
      <cell title="下单时间" value-align="right" :value="orderInfo.add_time"></cell>
      <box gap="20px 10px">
          <x-button type="warn" action-type="button" style="border-radius:5px; font-weight:bold; font-size:14px;" @click.native="pay()">去支付</x-button>
          </box>
  </group>
</div>    
</template>

<script>
    import { orderInfo } from '@/api/Goods'
    import { Loading, XHeader, Group, Cell, XButton, Box } from 'vux'
    export default {
        components: {
            Loading,XHeader,Group,Cell, XButton, Box
        },
        data() {
            return {
                isLoading: false,
                orderInfo: {
                    order_sn: '',
                    total_amount: '',
                    consignee: '',
                    mobile: '',
                    address: '',
                    add_time: '',
                }
            }
        },
        methods: {
            getOrderInfo() {
                orderInfo({ id: this.$route.query.order_id }).then(response => {
                    this.orderInfo = {
                        order_sn: response.order_sn,
                        total_amount: response.total_amount,
                        consignee: response.consignee,
                        mobile: response.mobile,
                        address: response.address,
                        add_time: response.add_time,
                    }
                    console.log(this.orderInfo)
                });
            },
            // 去支付
            pay() {
                window.location.href = process.env.SERVER_URL + '/index.php/mobile/Payment/getCode?order_id=' + this.$route.query.order_id + '&openid=' + sessionStorage.getItem('openid')
                // window.location.href = process.env.SERVER_URL + '/index.php/mobile/Payment/getPay?order_id=' + this.$route.query.order_id + '&openid=' + sessionStorage.getItem('openid')

            }
        },
        mounted() {
            this.getOrderInfo()
        }
    }
</script>
<style style="less">
#app {
		text-align: left;
        font-size:14px;
	}
.vux-label {
    font-size: 14px;
    font-weight: bold;
}
</style>
